﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ScrumDashboard.Library.Models;

namespace ScrumDashboardMvc.Models
{
    public class ToolbarViewData
    {
        public ToolbarViewData(IEnumerable<TeamProject> projects, IEnumerable<Sprint> sprints, IList<TeamSprint> teams, string displayName)
        {
            Projects = new SelectList(projects, "Name", "Name");
            Sprints = new SelectList(sprints, "Id", "Title");
            Teams = new SelectList(teams, "Id", "Title");
            DisplayName = displayName;
        }

        public SelectList Projects { get; set; }
        public SelectList Sprints { get; set; }
        public SelectList Teams { get; set; }

        public string DisplayName { get; set; }

        public void AddSelection(SelectList list, object value)
        {
            if (value != null)
            {
                foreach (SelectListItem item in list)
                {
                    if (item.Value == value.ToString())
                    {
                        item.Selected = true;
                    }
                }
            }
        }
    }
}